﻿(function(lib,config){
	/*
    config = {
        typeid: '1',// 弹窗类型 1=固定 2=全屏 3=锚点(保留)
        words: '话术1|话术2|话术3',
        bgcolor: '#ab2626|#333333',
        textcolor: '#9e3636|#ffffff',
        imglink: '/upload/20180521/201805211045251799.png|/upload/20180521/201805211045251799.png',
        weblink: '',// 商务通链接 注意：多个
        flashid: '0',// 保留
        positionid: '5',// 位置 当typeif=1时有效 (将屏幕分割成九宫格)取值：1~9 1=左上 2=左中 3=左右 4=中左 5=中中 6=中右 7=下左 8=下中 9=下右
        firsttime: '10',// 首次弹出时间 单位：秒 
        relapsetime: '30',// 普通弹出时间 单位：秒 0=关闭
        eachtime: '20', // 弹出后显示时间 单位：秒
        iscomapp: '1', //是否兼容百度 0=否 1=是
        identifier: 'centerswt'// 进入商务通的标识符
    };
    */
	
	/* words bgcolor textcolor imglink 可能有多个，用管道符号 | 分割*/
	var loadFunc=function(){
		var textAry=config.words.split('|'),bgcolorAry=config.bgcolor.split('|'),textcolorAry=config.textcolor.split('|'),imglinkAry=config.imglink.split('|'),weblinkAry=config.weblink.split('|');
		textAry[0] = textAry[0]||'';
		textAry[1] = textAry[1]||'';
		textAry[2] = textAry[2]||'';
		bgcolorAry[0] = bgcolorAry[0]||'';
		/*TODO 方法*/
			function getScrollTop(){ 
	var scrollTop=0;
	if(document.documentElement&&document.documentElement.scrollTop)
	{
		scrollTop=document.documentElement.scrollTop;
	}
	else if(document.body)
	{
		scrollTop=document.body.scrollTop;
	}
	return scrollTop;
}
function getClientHeight(){ 
	var clientHeight=0;
	if(document.body.clientHeight&&document.documentElement.clientHeight)
	{
		var clientHeight = (document.body.clientHeight<document.documentElement.clientHeight)?document.body.clientHeight:document.documentElement.clientHeight;        
	}
	else
	{
		var clientHeight = (document.body.clientHeight>document.documentElement.clientHeight)?document.body.clientHeight:document.documentElement.clientHeight;    
	}
	return clientHeight;
}

var _ua = navigator.userAgent,_ua_text = false,_position = "fixed"; 
if(_ua.indexOf('baiduboxapp')>-1){
	_ua_text = true;_position = "absolute";
}

var stVar = [];
stVar.push("<style type=\'text/css\'>");
stVar.push("#new_LR-BUBBLE{box-sizing: border-box;margin:0 5% 50% 5%;border-radius:10px;background-color:"+bgcolorAry[0]+" !important;border:2px solid #41c21f !important;}#LR-BUBBLE-NAME{color:#6D5220;font-weight:bold;}#LR-BUBBLE-MSG{color:#9E7039;font-weight:bold;height:auto;}#LR-BUBBLE-MSG img{width:32px;height:32px;}#new_LR-BUBBLE{margin:0 5% 10vh 5% !important;;-webkit-animation:shake-little 10s both infinite;-moz-animation:shake-little 10s both infinite;-ms-animation:shake-little 10s both infinite;animation:shake-little 10s both infinite;}.footcss{z-index:999999999999999999 !important;position:relative !important;}@-webkit-keyframes shake-little{0,20%{-webkit-transform:translate(0px,0px) rotate(0deg)}21%{-webkit-transform:translate(0px,0px) rotate(0deg)}21.3%{-webkit-transform:translate(-2px,2px) rotate(0.5deg)}21.6%{-webkit-transform:translate(0px,0px) rotate(0deg)}22%{-webkit-transform:translate(2px,-2px) rotate(-0.5deg)}22.3%{-webkit-transform:translate(0px,0px) rotate(0deg)}22.6%{-webkit-transform:translate(-2px,2px) rotate(0.5deg)}23%{-webkit-transform:translate(0px,0px) rotate(0deg)}23.3%{-webkit-transform:translate(2px,-2px) rotate(-0.5deg)}23.6%{-webkit-transform:translate(0px,0px) rotate(0deg)}24%{-webkit-transform:translate(2px,-2px) rotate(-0.5deg)}24.3%,100%{-webkit-transform:translate(0px,0px) rotate(0deg)}}</style>");

var o = document.createElement('div');
    o.innerHTML = stVar.join('');
    while(o.firstElementChild){
        document.body.appendChild(o.firstElementChild);
    };
var refer=document.referrer;var sosuo=refer.split(".")[1];var grep=null;var str=null;var key=null;var keyword=null;switch(sosuo){case "baidu":grep=/word\=.*\&/i;str=refer.match(grep)
keyword=str.toString().split("=")[1].split("&")[0];
key=decodeURIComponent(keyword);break;case "sogou":grep=/keyword\=.*\&/i;str=refer.match(grep)
keyword=str.toString().split("=")[1].split("&")[0];
key=decodeURIComponent(keyword);break;case "m":grep=/q\=.*\&/i;str=refer.match(grep)
keyword=str.toString().split("=")[1].split("&")[0];
key=decodeURIComponent(keyword);break;}
var a= /男科|前列腺|阳痿早泄|阳痿|早泄|包皮|包茎|包皮包茎|生殖感染|男科检查|龟头炎|尿道炎|附睾炎|睾丸炎|性功能|不孕不育|整形|龟头炎|精囊炎|附睾炎|睾丸炎|泌尿感染|精液异常|性功能障碍|勃起障碍|阴囊炎/i;
var b=/yyjs|myfc|tsjs|cgal|lylx/i;var str = document.title;var c=window.location.pathname;var key="疾病";
if(str.match(a)!=""){key=str.match(a);}else{key="疾病";}if(str.match(a)==null){key="疾病";}
var str2=""+textAry[1]+"<img style=\"max-width:100%;display: inline-block;vertical-align: middle;\" src=\"http://nkm.yyjl120.com/swt/20180518swt/smile.gif\">";
var d=new Date()
var weekday=new Array(7)
weekday[0]="日"
weekday[1]="一"
weekday[2]="二"
weekday[3]="三"
weekday[4]="四"
weekday[5]="五"
weekday[6]="六"
var str3="今天周" + weekday[d.getDay()] +"，"+textAry[2]+"";
stVar.push("<style type=\"text/css\">#new_LR-BUBBLE{ position:"+ _position +"!important; right: 0; display: none; width: 90%; margin: 0 5%; background-color:#fff7e4; color: #000; text-align: left; box-shadow: 0 5px 16px 0 rgba(0, 0, 0, .16);  border-radius:10px; z-index: 9999999; }#LR-BUBBLE-INSIDE{    margin: 10px; text-align: left; line-height:20px;  padding:5px; height:auto; }.LR-ICON { background-size: 32px auto !important; background-repeat: no-repeat !important; background-image: url(http://nkm.yyjl120.com/swt/20180518swt//mclose.png) !important; }#LR-BUBBLE-CLOSE { position: absolute; top: 1px; right: 3px; width: 26px; height: 26px; background-position: -3px -58px; }#LR-BUBBLE-MSG { height:10vh !important; margin-top: 5px; font-size: 14px; overflow: hidden; color: #520606 !important; }#LR-BUBBLE-NAME { font-weight: bold; color: #d6601b !important; font-size: 15px; }#LR-BUBBLE-AVATAR { width: 30px; height: 30px; border-radius: 13px; margin-right: 6px; vertical-align: top; box-shadow: 0 0 8px 0 rgba(0, 0, 0, .15); }.footerdh{width:100%; height:38px;}.footerdh img {width:100%; height:38px;border-radius:0 0 10px 10px;}<\/style>");
stVar.push("<div id=\"new_LR-BUBBLE\"  style=\"top:30%\"><span class=\"LR-ICON\" id=\"LR-BUBBLE-CLOSE\" onclick=\"closebar();\"></span><a href=\'http://swtyyjl.hxtg.org/LR/Chatpre.aspx?id=PKX31671888&lng=cn&p=http://"+window.location.host+"\'><div id=\'LR-BUBBLE-INSIDE\'><div id=\'LR-BUBBLE-title\' style=\'display: block;\'><img id=\'LR-BUBBLE-AVATAR\' src=\'http://nkm.yyjl120.com/swt/20180518swt/chat_left_img_share_cn.png\'><span id=\'LR-BUBBLE-NAME\'>九龙医院今日值班医生</span></div><div id=\'LR-BUBBLE-MSG\'>"+textAry[0]+"</div></div><div class=\"footerdh\"><img src=\"http://nkm.yyjl120.com/swt/20180518swt//footerhh.gif\"/><\/div></a><\/div>");

var o = document.createElement('div');
    o.innerHTML = stVar.join('');
    while(o.firstElementChild){
        document.body.appendChild(o.firstElementChild);
    };
var mini_href = window.location.href;
function toolkey() {
	document.getElementById('new_LR-BUBBLE').style.display='block';
document.getElementById('LR-BUBBLE-INSIDE').innerHTML="<div id=\'LR-BUBBLE-title\' style=\'display: block;\'><img id=\'LR-BUBBLE-AVATAR\' src=\'http://nkm.yyjl120.com/swt/20180518swt/chat_left_img_share_cn.png\'><span id=\'LR-BUBBLE-NAME\'>九龙医院今日值班医生</span></div><div id=\'LR-BUBBLE-MSG\'>"+textAry[0]+"</div>";
	setTimeout(toolkey2,8000);};
function toolkey2() {
document.getElementById('LR-BUBBLE-INSIDE').innerHTML="<div id=\'LR-BUBBLE-title\' style=\'display: block;\'><img id=\'LR-BUBBLE-AVATAR\' src=\'http://nkm.yyjl120.com/swt/20180518swt/chat_left_img_share_cn.png\'><span id=\'LR-BUBBLE-NAME\'>九龙医院今日值班医生</span></div><div id=\'LR-BUBBLE-MSG\'>"+str2+"</div>";
	setTimeout(toolkey3,8000);	};
function toolkey3() {
	document.getElementById('LR-BUBBLE-INSIDE').innerHTML="<div id=\'LR-BUBBLE-title\' style=\'display: block;\'><img id=\'LR-BUBBLE-AVATAR\' src=\'http://nkm.yyjl120.com/swt/20180518swt/chat_left_img_share_cn.png\'><span id=\'LR-BUBBLE-NAME\'>九龙医院今日值班医生</span></div><div id=\'LR-BUBBLE-MSG\'>"+str3+"</div>";};
function closebar() {
	document.getElementById('new_LR-BUBBLE').style.display='none';
	setTimeout(toolkey,20000);};
setTimeout(toolkey,5000);

  function addEvent(obj,type,fn){
	if(obj.attachEvent){
		obj.attachEvent('on'+type,function(){
			fn.call(obj);
		})
	}else{
		obj.addEventListener(type,fn,false);
	}
}

if(_ua_text){
	var _t_LRBUBBLE = document.getElementById('new_LR-BUBBLE').style.top;
	if(_t_LRBUBBLE==''){_t_LRBUBBLE=0;}		
		addEvent(window,'scroll',function(){
		document.getElementById('new_LR-BUBBLE').style.top = parseInt('40%')+(getScrollTop()/getClientHeight())*100 + '%' ;	
	});
}
		
	};
	lib.load(loadFunc);/*执行代码*/
})('{{lib}}','{{config}}');



